package com.cyufeng.blog.service;

import com.cyufeng.blog.entity.Email;
import com.cyufeng.blog.repository.EmailRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
/**
 * 联系管理员
 * @author Cyufeng
 * Data:2018.12.30
 */
@Service
public class EmailSerivce {
    @Autowired
    EmailRepository emailRepository;
//保存用户新增联系管理员的信息
    public String saveEmail(String title, String detail, String email) {
        try {
            Email newEmail = new Email();
            newEmail.setEmail(email);
            newEmail.setTitle(title);
            newEmail.setDetail(detail);
            newEmail.setMadeTime(new Date());
            emailRepository.save(newEmail);
            return "success";
        } catch (Exception e) {
            return "error";
        }

    }
}
